Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Fix router tests #139

Merged
merged 15 commits into from
Feb 3, 2020
Merged

Fix router tests #139

merged 15 commits into from
Feb 3, 2020

Conversation

Darkren
Copy link
Contributor

@Darkren Darkren commented Jan 29, 2020

Fixes #102

Changes:

  • Uncommented and fixed TestArbitrarySizeOneMessage
  • Uncommented and fixed TestArbitrarySizeMultipleMessagesByChunks
  • Fixed testPresentTimeout subtest of TestConn
  • Fixed possible memory leak in route group. Described in details in commit message 42b9559
  • Fixed testCloseTimeout subtest of TestConn
  • Improved performance of route group (we've been holding mutex much longer than we actually needed it)
  • Refactored route group and its tests a bit, cleaned up the code
  • Removed debug logs

Sir Darkrengarius and others added 10 commits January 29, 2020 13:09
Regarding memory leak. In the `Write` method of the route group we call
`writePacketAsync`. It returns `errCh` to us to wait the error from, this
channel is not buffered, so `writePacketAsync`'s goroutine actually blocks
while trying to pass error to this channel. But `Write` blocks on `select`
waiting either error from `errCh` or error from write deadline struct. And
if it gets deadline error, it just returns without waiting for any error from
`errCh`, making `writePacketAsync` block forever on sending to the channel.
And we might have had a lot of such running goroutines
@Darkren
Copy link
Contributor Author

Darkren commented Jan 29, 2020

Just one more subtest of TetsConn left to be fixed. And code needs to be cleaned up

@Darkren Darkren changed the title [WIP] Fix router tests Fix router tests Jan 30, 2020
@Darkren Darkren requested review from nkryuchkov, evanlinjin and Kifen and removed request for nkryuchkov January 30, 2020 18:41
Copy link
Contributor

@evanlinjin evanlinjin left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Awesome work! Just a small query for clearer commenting.

require.True(t, rg0.isClosed())
require.True(t, rg1.isRemoteClosed())
require.True(t, rg1.isClosed())
require.True(t, rg2.isRemoteClosed())
// rg1 should be done (not getting any new data, returning `io.EOF` on further reads)
// but not closed
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Should be specify:

// rg1 should be closed for reads (returning `io.EOF` on further reads), but not on writes.

Is this the intended behaviour?

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

@evanlinjin yep. io.EOF is only returned when the connection is broken (we test this via isRemoteClosed) and no data left on the wire (we check the readCh for it). this was the only way to make route group behave like the usual connection, and also it seems like the most correct one to me

Copy link
Contributor

@nkryuchkov nkryuchkov left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Great job!

pkg/router/route_group.go Outdated Show resolved Hide resolved
Copy link
Contributor

@Kifen Kifen left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Good job!

@jdknives jdknives merged commit d26feb7 into skycoin:milestone2 Feb 3, 2020
@Darkren Darkren deleted the fix/router-tests branch February 7, 2020 11:25
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

Router test failure
5 participants